{% extends 'mould/index.html' %}

{% block title %}
    Purchase-Histry
{% endblock %}

{% block body %}
    <div class="container">
        <div class="record-box1-com">
            <div class="panel panel-primary ">
                <div class="panel-heading">
                    <h3 class="panel-title text-center">个人信息</h3>
                </div>
                <div class="panel-body record-block-com-p">
                    <form class="form-horizontal" id='self-from' action="/modify_userinfo" method="POST">
                        <div class="form-group">
                            <div class="col-sm-12">
                                <input type="email" class="form-control" id="email" disabled="disabled"
                                       placeholder="邮箱：{{ user_self_data.email }}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <input type="text" class="form-control" id="tel" name="tel"
                                       placeholder="手机：{{ user_self_data.tel }}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <input type="password" class="form-control" id="oldPasswd" name="oldPasswd"
                                       placeholder="旧密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <input type="password" class="form-control" id="newPasswd1" name="newPasswd1"
                                       placeholder="新密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-12">
                                <input type="password" class="form-control" id="newPasswd2" name="newPasswd2"
                                       placeholder="再次确认新密码">
                            </div>
                        </div>
                        <div class="form-group text-center">
                            <div class="col-sm-12">
                                <input type="submit" id="subfrom" class="btn btn-primary" value="提交修改信息">

                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
        <div class="record-box2-com table-bordered container">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>域名</th>
                    <th>交易类型</th>
                    <th>交易时间</th>
                    <th>交易价格</th>
                </tr>
                </thead>
                <tbody class="record-font">
                {% if msg_tag == '0' %}
                    <tr>
                        <td colspan="4" class="record-font2">没有购买记录</td>
                    </tr>
                {% endif %}
                {% for key,value in data.items %}
                    <tr>
                        <td><a href="detail-{{ value.id }}.html">{{ key }}</a></td>
                        <td>{{ value.type }}</td>
                        <td>{{ value.date }}</td>
                        <td><span style="color: #ff4500;">￥</span>{{ value.price }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    </div>

    <script src="/static/js/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
            if ($('#tel').val() == '' && $('#oldPasswd').val() == '' &&
                $('#newPasswd1').val() == '' && $('#newPasswd2').val() == '') {
                $('#subfrom').attr('disabled', 'disabled');
            }
            ;
        });
        $('#tel').change(function () {
            if ($('#tel').val().length == 11) {
                $('#subfrom').removeAttr('disabled');
            }
            ;
        });

        $('#newPasswd2').change(function () {
            if ($('#oldPasswd').val() != '' ) {
                if ($('#newPasswd1').val() == $('#newPasswd2').val()
                    && $('#newPasswd2').val().length >= 6) {
                    $('#subfrom').removeAttr('disabled');
                };
            }
            ;
        });
    </script>
{% endblock %}
